package market

import (
	"context"
	pb "git.mycaigou.com/gfyx/micro-gfyx-oppty-service/proto/micro_gfyx_oppty_service_proto/micro-gfyx-oppty-service/market"
	"git.mycaigou.com/gfyx/micro-gfyx-oppty-service/service/market/outbound_account"
	"git.myscrm.cn/golang/stark/v4"
)

type OutboundAccountServer struct {
	outboundAccountService outbound_account.OutboundAccountServiceIface
}

func NewOutboundAccountServer(outboundAccountService outbound_account.OutboundAccountServiceIface) pb.OutboundAccountServiceServer {
	return &OutboundAccountServer{
		outboundAccountService: outboundAccountService,
	}
}

func (o *OutboundAccountServer) ExpenseDetail(ctx context.Context, request *pb.ExpenseDetailRequest) (*pb.ExpenseDetailResponse, error) {
	//resp := &pb.ExpenseDetailResponse{}
	resp, err := o.outboundAccountService.GetExpenseDetail(ctx, request)
	return resp, err
}

func (o *OutboundAccountServer) GetSeatInfoList(ctx context.Context, request *pb.GetSeatInfoListRequest) (*pb.GetSeatInfoListResponse, error) {
	resp, err := o.outboundAccountService.GetSeatInfoList(ctx, request)
	if err != nil {
		stark.Logger.Errorf(ctx, "grpc GetSeatInfoList request:%+v, err:%s", request, err)
		return nil, err
	}
	stark.Logger.Infof(ctx, "grpc GetSeatInfoList request:%+v, succeed", request)
	return resp, nil
}

func (o *OutboundAccountServer) GetRobotList(ctx context.Context, request *pb.GetRobotListRequest) (*pb.GetRobotListResponse, error) {
	resp, err := o.outboundAccountService.GetRobotList(ctx, request)
	if err != nil {
		stark.Logger.Errorf(ctx, "grpc GetRobotList request:%+v, err:%s", request, err)
		return nil, err
	}
	stark.Logger.Infof(ctx, "grpc GetRobotList request:%+v, succeed", request)
	return resp, nil
}

func (o *OutboundAccountServer) GetPhoneList(ctx context.Context, request *pb.GetPhoneListRequest) (*pb.GetPhoneListResponse, error) {
	resp, err := o.outboundAccountService.GetPhoneList(ctx, request)
	if err != nil {
		stark.Logger.Errorf(ctx, "grpc GetPhoneList request:%+v, err:%s", request, err)
		return nil, err
	}
	stark.Logger.Infof(ctx, "grpc GetPhoneList request:%+v, succeed", request)
	return resp, nil
}

func (o *OutboundAccountServer) GetAccountDetail(ctx context.Context, request *pb.GetAccountDetailRequest) (*pb.GetAccountDetailResponse, error) {
	resp, err := o.outboundAccountService.GetAccountDetail(ctx, request)
	if err != nil {
		stark.Logger.Errorf(ctx, "grpc GetAccountDetail request:%+v, err:%s", request, err)
		return nil, err
	}
	stark.Logger.Infof(ctx, "grpc GetAccountDetail request:%+v, succeed", request)
	return resp, nil
}

func (o *OutboundAccountServer) SaveAccount(ctx context.Context, request *pb.SaveAccountRequest) (*pb.SaveAccountResponse, error) {
	resp, err := o.outboundAccountService.SaveAccount(ctx, request)
	if err != nil {
		stark.Logger.Errorf(ctx, "grpc SaveAccount request:%+v, err:%s", request, err)
		return nil, err
	}
	stark.Logger.Infof(ctx, "grpc SaveAccount request:%+v, succeed", request)
	return resp, nil
}
